package com.testfileupload.uploadimg.design.proxy.approve;


public class GamePlayer implements IGamePlayer {
    private String name = "";
    private GamePlayProxy gamePlayProxy = null;

    public GamePlayer(String name)  {
        this.name = name;
    }

    @Override
    public void login(String user, String password) {
        if (isProxy()) {
            System.out.println("登录名为" + user + "的用户" + this.name + "登录");
        } else {
            System.out.println("请用指定的代理访问");
        }

    }

    @Override
    public void killBoss() {
        if (isProxy()) {
            System.out.println(this.name + "杀掉bose");
        } else {
            System.out.println("请用指定的代理访问");
        }

    }

    @Override
    public void upgrade() {
        if (isProxy()) {
            System.out.println(this.name + "升级");
        } else {
            System.out.println("请用指定的代理访问");
        }

    }

    @Override
    public IGamePlayer getProxy() {
        this.gamePlayProxy = new GamePlayProxy(this);
        return this.gamePlayProxy;
    }

    //是否代理访问
    private Boolean isProxy() {
        if (this.gamePlayProxy == null) {
            return false;
        } else {
            return true;
        }
    }
}
